package tx.bjdacp.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bjdacp.model.*;
import tx.bjdacp.dao.*;
import tx.bjdacp.service.*;
import tx.bjdacp.vo.query.*;


@Entity
@Table(name = "bjdacp_drug_sell_unit_prepare")
public class DrugSellUnitPrepare extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "药品经营企业筹建";
	public static final String ALIAS_DRUG_SELL_UNIT_PREPARE_ID = "drugSellUnitPrepareId";
	public static final String ALIAS_ZONE_ID = "zoneId";
	public static final String ALIAS_ACCEPT_DATE = "受理时间";
	public static final String ALIAS_APPLY_PERSON = "申报人";
	public static final String ALIAS_ACCEPT_CODE = "受理号";
	public static final String ALIAS_ZONE_NAME = "所在镇";
	public static final String ALIAS_APPLY_ADDRESS = "详细申报地址";
	public static final String ALIAS_MEASURE_RESULT = "测量结果";
	public static final String ALIAS_MEASURE_DATE = "测量时间";
	public static final String ALIAS_TIME_LIMIT = "时限";
	public static final String ALIAS_PHONE = "电话";
	public static final String ALIAS_ACCREDITED_PERSON = "被授权人";
	public static final String ALIAS_REMARK = "备注";

	//date formats
	public static final String FORMAT_ACCEPT_DATE = DATE_FORMAT;
	public static final String FORMAT_MEASURE_DATE = DATE_FORMAT;


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * drugSellUnitPrepareId       db_column: drug_sell_unit_prepare_id
     */
	
	private java.lang.Integer drugSellUnitPrepareId;
    /**
     * zoneId       db_column: zone_id
     */
	
	private java.lang.Integer zoneId;
    /**
     * 受理时间       db_column: accept_date
     */
	
	private java.util.Date acceptDate;
    /**
     * 申报人       db_column: apply_person
     */
	@Length(max=100)
	private java.lang.String applyPerson;
    /**
     * 受理号       db_column: accept_code
     */
	@Length(max=100)
	private java.lang.String acceptCode;
    /**
     * 所在镇       db_column: zone_name
     */
	@Length(max=100)
	private java.lang.String zoneName;
    /**
     * 详细申报地址       db_column: apply_address
     */
	@Length(max=500)
	private java.lang.String applyAddress;
    /**
     * 测量结果       db_column: measure_result
     */
	@Length(max=100)
	private java.lang.String measureResult;
    /**
     * 测量时间       db_column: measure_date
     */
	
	private java.util.Date measureDate;
    /**
     * 时限       db_column: time_limit
     */
	@Length(max=100)
	private java.lang.String timeLimit;
    /**
     * 电话       db_column: phone
     */
	@Length(max=100)
	private java.lang.String phone;
    /**
     * 被授权人       db_column: accredited_person
     */
	@Length(max=100)
	private java.lang.String accreditedPerson;
    /**
     * 备注       db_column: remark
     */
	@Length(max=1000)
	private java.lang.String remark;
	//columns END


	public DrugSellUnitPrepare(){
	}

	public DrugSellUnitPrepare(
		java.lang.Integer drugSellUnitPrepareId
	){
		this.drugSellUnitPrepareId = drugSellUnitPrepareId;
	}



	public void setDrugSellUnitPrepareId(java.lang.Integer value) {
		this.drugSellUnitPrepareId = value;
	}

	@Id	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "drug_sell_unit_prepare_id", unique = true, nullable = false, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getDrugSellUnitPrepareId() {
		return this.drugSellUnitPrepareId;
	}

	@Column(name = "zone_id", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getZoneId() {
		return this.zoneId;
	}

	public void setZoneId(java.lang.Integer value) {
		this.zoneId = value;
	}

	@Transient
	public String getAcceptDateString() {
		return DateConvertUtils.format(getAcceptDate(), FORMAT_ACCEPT_DATE);
	}
	public void setAcceptDateString(String value) {
		setAcceptDate(DateConvertUtils.parse(value, FORMAT_ACCEPT_DATE,java.util.Date.class));
	}

	@Column(name = "accept_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getAcceptDate() {
		return this.acceptDate;
	}

	public void setAcceptDate(java.util.Date value) {
		this.acceptDate = value;
	}

	@Column(name = "apply_person", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getApplyPerson() {
		return this.applyPerson;
	}

	public void setApplyPerson(java.lang.String value) {
		this.applyPerson = value;
	}

	@Column(name = "accept_code", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getAcceptCode() {
		return this.acceptCode;
	}

	public void setAcceptCode(java.lang.String value) {
		this.acceptCode = value;
	}

	@Column(name = "zone_name", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getZoneName() {
		return this.zoneName;
	}

	public void setZoneName(java.lang.String value) {
		this.zoneName = value;
	}

	@Column(name = "apply_address", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getApplyAddress() {
		return this.applyAddress;
	}

	public void setApplyAddress(java.lang.String value) {
		this.applyAddress = value;
	}

	@Column(name = "measure_result", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getMeasureResult() {
		return this.measureResult;
	}

	public void setMeasureResult(java.lang.String value) {
		this.measureResult = value;
	}

	@Transient
	public String getMeasureDateString() {
		return DateConvertUtils.format(getMeasureDate(), FORMAT_MEASURE_DATE);
	}
	public void setMeasureDateString(String value) {
		setMeasureDate(DateConvertUtils.parse(value, FORMAT_MEASURE_DATE,java.util.Date.class));
	}

	@Column(name = "measure_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getMeasureDate() {
		return this.measureDate;
	}

	public void setMeasureDate(java.util.Date value) {
		this.measureDate = value;
	}

	@Column(name = "time_limit", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getTimeLimit() {
		return this.timeLimit;
	}

	public void setTimeLimit(java.lang.String value) {
		this.timeLimit = value;
	}

	@Column(name = "phone", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getPhone() {
		return this.phone;
	}

	public void setPhone(java.lang.String value) {
		this.phone = value;
	}

	@Column(name = "accredited_person", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getAccreditedPerson() {
		return this.accreditedPerson;
	}

	public void setAccreditedPerson(java.lang.String value) {
		this.accreditedPerson = value;
	}

	@Column(name = "remark", unique = false, nullable = true, insertable = true, updatable = true, length = 1000)
	public java.lang.String getRemark() {
		return this.remark;
	}

	public void setRemark(java.lang.String value) {
		this.remark = value;
	}


	private Set drugSellUnits = new HashSet(0);
	public void setDrugSellUnits(Set<DrugSellUnit> drugSellUnit){
		this.drugSellUnits = drugSellUnit;
	}

	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "drugSellUnitPrepare")
	public Set<DrugSellUnit> getDrugSellUnits() {
		return drugSellUnits;
	}

	private Zone zone;
	public void setZone(Zone zone){
		this.zone = zone;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "zone_id",nullable = false, insertable = false, updatable = false) 
	})
	public Zone getZone() {
		return zone;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("DrugSellUnitPrepareId",getDrugSellUnitPrepareId())
			.append("ZoneId",getZoneId())
			.append("AcceptDate",getAcceptDate())
			.append("ApplyPerson",getApplyPerson())
			.append("AcceptCode",getAcceptCode())
			.append("ZoneName",getZoneName())
			.append("ApplyAddress",getApplyAddress())
			.append("MeasureResult",getMeasureResult())
			.append("MeasureDate",getMeasureDate())
			.append("TimeLimit",getTimeLimit())
			.append("Phone",getPhone())
			.append("AccreditedPerson",getAccreditedPerson())
			.append("Remark",getRemark())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getDrugSellUnitPrepareId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof DrugSellUnitPrepare == false) return false;
		if(this == obj) return true;
		DrugSellUnitPrepare other = (DrugSellUnitPrepare)obj;
		return new EqualsBuilder()
			.append(getDrugSellUnitPrepareId(),other.getDrugSellUnitPrepareId())
			.isEquals();
	}
}

